const baseUrl = 'http://sph-h5-api.atguigu.cn'

export default function(params){
  return new Promise((reslove,reject)=>{
    wx.showLoading({
      title: '正在加载中...',
    })
    const header = {}
    const token = wx.getStorageSync('token')
    if(token){
      header.token = token
    }
    wx.request({
      url:baseUrl+params.url,
      method:params.method || 'GET',
      data:params.data || {},
      header,
      success(res){
        reslove(res.data)
      },
      fail(error){
        reject(error)
      },
      complete(){
        wx.hideLoading()
      }
    })
  })
}